//member_object.cpp
//four cases of generating implicit, nontrivial default constructors
//two common misunderstanding
//1. A default constructor is synthesized for every class that does not define one
//2. The compiler-synthesized default constructor provides 
//   explicit default initializers for each data member declared within the class
//

#include <iostream>
#include <cstdio>
using namespace std;

//member class object
class Foo
{
public:
  Foo(){ cout<<"Foo()"<<endl;}
};

class Bar0
{
public:
  Foo foo;
  char *str;
};
class Bar1
{
public:
  Foo foo;
  char *str;
  Bar1(){str = 0;cout<<"Bar1()"<<endl;}
};

int main(void)
{
 
  cout<<"Bar0----------------------"<<endl;
  Bar0 bar0;
  printf("char* is %p\n",bar0.str);

  cout<<"Bar1----------------------"<<endl;
  Bar1 bar1;
  printf("char* is %p\n", bar1.str);

  return 0;
}
